package com.jic.member.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.MememberIntegralExchange;
import com.jic.member.mapper.MememberIntegralExchangeMapper;
import com.jic.member.service.MememberIntegralExchangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 会员积分规则兑换产品-兑换付费表
 * @author : 
 * @email : 
 * @since : 2020-04-02 03:26:59
 * @version : v1.0.0
 */
@Service
public class MememberIntegralExchangeServiceImpl implements MememberIntegralExchangeService {

    @Autowired
    private MememberIntegralExchangeMapper mememberIntegralExchangeMapper;

    @Override
    public long insert(MememberIntegralExchange mememberIntegralExchange) {
        long flag = mememberIntegralExchangeMapper.insert(mememberIntegralExchange);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return mememberIntegralExchangeMapper.delete(id);
    }

    @Override
    public long update(MememberIntegralExchange mememberIntegralExchange) {
        return mememberIntegralExchangeMapper.update(mememberIntegralExchange);
    }

    @Override
    public MememberIntegralExchange queryByPrimaryKey(Long id){
        return mememberIntegralExchangeMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<MememberIntegralExchange> query(MememberIntegralExchange mememberIntegralExchange){
        return mememberIntegralExchangeMapper.query(mememberIntegralExchange);
    }

    @Override
    public PageResult<MememberIntegralExchange> queryPage(MememberIntegralExchange mememberIntegralExchange, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<MememberIntegralExchange> list = mememberIntegralExchangeMapper.queryPage(startIndex, pageQuery.getLimit(), mememberIntegralExchange);
        long count = mememberIntegralExchangeMapper.queryPageCount(mememberIntegralExchange);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}